<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * 这个表中存放的是每个订单的头部公共信息
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_num')->unique()->index()->comment('系统的订单号当前时间戳加上一个3位随机数');
            $table->enum('status',['未付款','已付款','已发货','待收货','已收货','待评价','已完成'])->comment('当前订单的状态');
            $table->unsignedInteger('user_id')->index()->comment('用户编号');
            $table->unsignedInteger('address_id')->index()->comment('地址编号');
            $table->unsignedInteger('totalprice')->comment('订单总金额');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
